//
//  TelepathyDataSource.m
//  tcpoctest
//
//  Created by apple on 13-8-5.
//  Copyright (c) 2013年 gump. All rights reserved.
//

#import "TelepathyDataSource.h"
#import "telepathyInfo.h"

@implementation TelepathyDataSource

-(id)init
{
    self = [super init];
    if (self != nil) {
        pthread_mutex_init(&mutexTelep, 0);
        self.iCandle = 0;
        self.LightBackType = TELEP_LT_SUCCESS;
        self.curinfo = nil;
        
        telepathyDic = [[NSMutableDictionary alloc] init];
    }
    
    return self;
}

-(void)SetGetUser:(NSString *)strmail
{
    pthread_mutex_lock(&mutexTelep);
    
    self.strGetUser = strmail;
    
    pthread_mutex_unlock(&mutexTelep);
}

-(NSString *)GetUser
{
    NSString *strmail = @"";
    
    pthread_mutex_lock(&mutexTelep);
    
    strmail = self.strGetUser;
    
    pthread_mutex_unlock(&mutexTelep);
    
    return strmail;
}

-(void)DelAllTeleDic
{
    pthread_mutex_lock(&mutexTelep);
    
    [telepathyDic removeAllObjects];
    
    pthread_mutex_unlock(&mutexTelep);
}

-(void)AddTelepDic:(telepathyInfo *)tinfo
{
    pthread_mutex_lock(&mutexTelep);
    
    if (tinfo != nil) {
        [telepathyDic setObject:tinfo forKey:tinfo.strid];
    }
    
    pthread_mutex_unlock(&mutexTelep);
}

-(telepathyInfo *)GetTelepInfoByID:(NSString *)strid
{
    telepathyInfo *tinfo = nil;
    
    pthread_mutex_lock(&mutexTelep);
    
    tinfo = [telepathyDic objectForKey:strid];
    
    pthread_mutex_unlock(&mutexTelep);
    
    return tinfo;
}

@end
